package com.jimmy.medical.entity;

import java.text.DecimalFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * 指标
 * 
 * @author jimmy
 * @since 0.1
 */
@Entity
@Table(name = "measures")
public class Measures extends AbstractEntity {
	private static final long serialVersionUID = 429312832148608091L;
	/** 指标名称*/
	@Column(name = "name", length = 50)
	private String name;
	/** 指标类型*/
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "type_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private SysCode type;
	/** 所属分类,多个逗号隔开*/
	@Column(name = "sorts", length = 50)
	private String sorts;
	/** 是否独立指标*/
	@Column(name = "is_independent", length = 2)
	private String isIndependent;
	/** 是否常规指标*/
	@Column(name = "is_normal", length = 2)
	private String isNormal;
	/** 首字母*/
	@Column(name = "first_letter", length = 10)
	private String firstLetter; 
	/** 指标数据计量单位*/
	@Column(name = "unit", length = 20)
	private String unit;
	/** 父指标项(用于复合指标)*/
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id")
    @NotFound(action = NotFoundAction.IGNORE)	
    private Measures parent;
	/** 指标的标准值(上限)*/
	@Column(name = "upper_standard_value")
	private Float upperStandardValue;
	/** 指标的标准值(下限)*/
	@Column(name = "lower_standard_value")
	private Float lowerStandardValue;
	/** 指标描述*/
	@Column(name="description", length = 500)
	private String description;
	
	/** 异常解读*/
	@Column(name="exceptions", length = 500)
	private String exceptions;
	/** 指标偏高的说明*/
	@Column(name="upper_error", length = 500)
	private String upperError;
	/** 指标偏低的说明*/
	@Column(name="lower_error", length = 500)
	private String lowerError;
	/** 表最高值*/
	@Column(name = "chart_max_value")
	private Float chartMaxValue;
	/** 表最低值*/
	@Column(name = "chart_min_value")
	private Float chartMinValue;
	/** 表刻度数量(最高值和最低值的差值)*/
	@Column(name = "chart_d_value")
	private Float chartDValue;
	/** 状态,1：启用;0:未启用*/
	@Column(name = "status")
	private String status;
	/** 排序*/
	@Column(name = "orders")
	private Integer orders;
	
	@Column(name = "create_time", length = 20)
	private String createTime;
	@Column(name = "create_user", length = 50)
	private String createUser;
	@Column(name = "update_time")
	private String updateTime;
	@Column(name = "update_user", length = 50)
	private String updateUser;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public Measures getParent() {
		return parent;
	}
	public void setParent(Measures parent) {
		this.parent = parent;
	}
	public Float getUpperStandardValue() {
		return upperStandardValue;
	}
	public String getUpperStandardValueStr() {
		DecimalFormat df = new DecimalFormat("0.00");
		try {
			return df.format(upperStandardValue);
		} catch(Exception e) {
			return "";
		}
	}
	public void setUpperStandardValue(Float upperStandardValue) {
		this.upperStandardValue = upperStandardValue;
	}
	public Float getLowerStandardValue() {
		return lowerStandardValue;
	}
	public String getLowerStandardValueStr() {
		DecimalFormat df = new DecimalFormat("0.00");
		try {
			return df.format(lowerStandardValue);
		} catch(Exception e) {
			return "";
		}
	}
	public void setLowerStandardValue(Float lowerStandardValue) {
		this.lowerStandardValue = lowerStandardValue;
	}
	public SysCode getType() {
		return type;
	}
	public void setType(SysCode type) {
		this.type = type;
	}
	public String getFirstLetter() {
		return firstLetter;
	}
	public void setFirstLetter(String firstLetter) {
		this.firstLetter = firstLetter;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public String getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	
	public String getTypeCn() {
		return type.getName();
	}
	public String getSorts() {
		return sorts;
	}
	public void setSorts(String sorts) {
		this.sorts = sorts;
	}
	public String getIsIndependent() {
		return isIndependent;
	}
	public void setIsIndependent(String isIndependent) {
		this.isIndependent = isIndependent;
	}
	public String getIsNormal() {
		return isNormal;
	}
	public void setIsNormal(String isNormal) {
		this.isNormal = isNormal;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getExceptions() {
		return exceptions;
	}
	public void setExceptions(String exceptions) {
		this.exceptions = exceptions;
	}
	public String getUpperError() {
		return upperError;
	}
	public void setUpperError(String upperError) {
		this.upperError = upperError;
	}
	public String getLowerError() {
		return lowerError;
	}
	public void setLowerError(String lowerError) {
		this.lowerError = lowerError;
	}
	public Float getChartMaxValue() {
		return chartMaxValue;
	}
	public void setChartMaxValue(Float chartMaxValue) {
		this.chartMaxValue = chartMaxValue;
	}
	public Float getChartMinValue() {
		return chartMinValue;
	}
	public void setChartMinValue(Float chartMinValue) {
		this.chartMinValue = chartMinValue;
	}
	public Float getChartDValue() {
		return chartDValue;
	}
	public void setChartDValue(Float chartDValue) {
		this.chartDValue = chartDValue;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
}
